from selenium.webdriver.common.by import By
import time


class Tools:
    def __init__(self, driver):
        # driver:浏览器，只在你传递进来的浏览器操作
        self.driver = driver
        self.driver.maximize_window()
        self.driver.implicitly_wait(10)

    def visit(self, url):
        # url:网页网址
        self.driver.get(url)
        time.sleep(2)

    def by_css(self, css):
        return self.driver.find_element(By.CSS_SELECTOR, css)

    def by_link(self, link):
        return self.driver.fing_element(By.PARTIAL_LINK_TEXT, link)

    def quit(self):
        self.driver.quit()
